package com.web.dao;

import com.web.entity.PoundageConfig;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * @author FDjavaone
 */
public interface PoundageConfigMapper {

    @Delete({
            "delete from t_poundage_config",
            " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into t_poundage_config (profit_withdraw, profit_transfer,merchant_withdraw, ",
            " msk_sale,msk_sale_p,msk_sale_c, create_time, ",
            " modify_time)",
            " values (#{profitWithdraw,jdbcType=DECIMAL}, #{profitTransfer,jdbcType=DECIMAL}, #{merchantWithdraw,jdbcType=DECIMAL}, ",
            " #{mskSale,jdbcType=DECIMAL},#{mskSaleP,jdbcType=DECIMAL},#{mskSaleC,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, ",
            " #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insert(PoundageConfig record);

    @InsertProvider(type = PoundageConfigSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insertSelective(PoundageConfig record);


    @Select({
            "select",
            " id, profit_withdraw, profit_transfer,merchant_withdraw, msk_sale,msk_sale_p,msk_sale_c, create_time, modify_time",
            " from t_poundage_config",
            " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "profit_withdraw", property = "profitWithdraw", jdbcType = JdbcType.DECIMAL),
            @Result(column = "profit_transfer", property = "profitTransfer", jdbcType = JdbcType.DECIMAL),
            @Result(column = "merchant_withdraw", property = "merchantWithdraw", jdbcType = JdbcType.DECIMAL),
            @Result(column = "msk_sale", property = "mskSale", jdbcType = JdbcType.DECIMAL),
            @Result(column = "msk_sale_p", property = "mskSaleP", jdbcType = JdbcType.DECIMAL),
            @Result(column = "msk_sale_c", property = "mskSaleC", jdbcType = JdbcType.DECIMAL),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    PoundageConfig selectByPrimaryKey(Long id);


    @UpdateProvider(type = PoundageConfigSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(PoundageConfig record);

    @Update({
            "update t_poundage_config",
            " set profit_withdraw = #{profitWithdraw,jdbcType=DECIMAL},",
            " profit_transfer = #{profitTransfer,jdbcType=DECIMAL},",
            " merchant_withdraw = #{merchantWithdraw,jdbcType=DECIMAL},",
            " msk_sale = #{mskSale,jdbcType=DECIMAL},",
            " msk_sale_p = #{mskSaleP,jdbcType=DECIMAL},",
            " msk_sale_c = #{mskSaleC,jdbcType=DECIMAL},",
            " create_time = #{createTime,jdbcType=TIMESTAMP},",
            " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
            " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(PoundageConfig record);
}